package com.ziven.common.widget.value;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public class TextLine extends Value {

    public static TextLine lines(int lines) {
        return new TextLine(lines);
    }

    private TextLine(int lines) {
        value = lines;
    }

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        if(!(value instanceof Integer)) {
            return;
        }
        int lines = (int) value;
        helper.getViewNulls().doNotNull(view -> {
            if(view instanceof TextView) {
                ((TextView) view).setLines(lines);
            }
        });
    }
}
